<?php
function write_menu_news($stSQL,$filehtm,$hreftname)
{	
		$result = mysql_query($stSQL);
        $totalRows=mysql_num_rows($result);
		if($totalRows>0)
		{
		  while ($row = mysql_fetch_array ($result))
		   {
		   
		  $res = mysql_query($stsubSQL); 
		      
			  $strOption1 ="<tr align=\"left\"><td>\n";
			  $strOption1 .="<a class=\"mainlevel\"";
			  //if ($row['parent_id']==0)
			  $submenu ="onclick=\"return showhide('".$row["No"]."');\" "; 
			  $catname=vietdecode($row["Name"]);
			  // NOT HTACCESS $strOption2 ="href=\"".$hreftname."&cat=".$row["No"]."\">"; 
			  
			  	  $strOption2 ="href=\"news{$row["No"]}-s0-p0-{$catname}.html\">";
			  	 $strOption2 .= $row["Name"];

			   if ($row['categories_image']<>"") 
			  $strOption2 .= "&nbsp;<img border=0 src=\"{$row['categories_image']}\">\n";
			  			  $strOption2 .= "</a>\n";
						  
			  $strOption2 .= "<div id=menu".$row["No"]." style=\"padding-left:5px;padding-bottom:5px;line-height:25px; background: url(./images/menu_sep.png) 0 100% repeat-x;margin-bottom:3px;";
			  $strOption2 .= "".'<? if($_REQUEST["parent"]!='.$row["No"].') echo "DISPLAY: none";?>'."";	
			  $strOption2 .= "\">\n";
			  
			  $subSQL="select categories_id as No, ";
			  $subSQL .="categories_name As Name ";
			  $subSQL .="from news_cats WHERE categories_status=0 and parent_id=".$row["No"]." order by sort_order ASC";
			  $res = mysql_query($subSQL);
       		  $total=mysql_num_rows($res);
       		  $tamthoi=0;
       		  $strOption3="";
			  while ($r = mysql_fetch_array ($res))
		   		{
		   			$tamthoi=5;
			  $strOption3.="<a class=\"sublevel\"";
			//not htaccess  $strOption3 .= "href=\"".$hreftname."&parent=".$row["No"]."&cat=".$r["No"]."\"> ";
			$catname=vietdecode($r["Name"]);
			  
			    $strOption3.=" href=\"news{$r["No"]}-s{$row["No"]}-p0-{$catname}.html\"> ";
			    
			  $strOption3 .= $r["Name"]."</a><br>\n";
			  
			    }
			    
			//  $strOption3 .= "</div></td></tr>";
			  if ($tamthoi==0) 
			  $strOption.=$strOption1.$strOption2.$strOption3."</div></td></tr>";
			
			  else $strOption.=$strOption1.$submenu.$strOption2.$strOption3."</div></td></tr>";
			  
		   }
		}

		$pathfile ="../html/".$filehtm;			
		$ft=fopen($pathfile,"w");	   		
		if(fwrite($ft,$strOption))
			return true;
		else
			return false;

}

?>